﻿[CategoryOrder("基础配置", 0)]
[CategoryOrder("数据访问层配置", 1)]
[CategoryOrder("业务逻辑层配置", 2)]
public class CodeConfig : XCode.UI.ICodeConfig
{
    public CodeConfig()
    {
 
    }
 
    private string baseDataBaseProvidrerNameSpace;
    private string petapocoNameSpace;
    private string baseEntityNameSpace;
    private string baseDataServiceNameSpace;
    private string baseDomainNameSpace;
    private string baseServiceProxyNameSpace;
    private string entityNameFormat;
    private string entityNameSpace;
    private string entityOutputPath;
    private string dataServiceNameFormat;
    private string dataServiceNameSpace;
    private string dataServiceOutputPath;
    private string serviceProxyNameFormat;
    private string serviceProxyNameSpace;
    private string serviceProxyOutputPath;
    private string domainNameFormat;
    private string domainNameSpace;
    private string domainOutputPath;
    private string removeTablePrefix;


    [Category("基础配置")]
    [Description("移除表前缀")]
    public string RemoveTablePrefix
    {
        get
        {
            return removeTablePrefix;
        }
        set
        {
            removeTablePrefix = value;
        }
    }
    [Category("基础配置")]
    [Description("数据提供者基类")]
    public string BaseDataBaseProvidrerNameSpace
    {
        get
        {
            return baseDataBaseProvidrerNameSpace;
        }
        set
        {
            baseDataBaseProvidrerNameSpace = value;
        }
    }
    [Category("基础配置")]
    [Description("PetaPoco名称空间")]
    public string PetapocoNameSpace
    {
        get { return petapocoNameSpace; }
        set { petapocoNameSpace = value; }
    }
    [Category("基础配置")]
    [Description("数据实体基类名称空间")]
    public string BaseEntityNameSpace
    {
        get { return baseEntityNameSpace; }
        set { baseEntityNameSpace = value; }
    }
    [Category("基础配置")]
    [Description("数据服务基类名称空间")]
    public string BaseDataServiceNameSpace
    {
        get { return baseDataServiceNameSpace; }
        set { baseDataServiceNameSpace = value; }
    }
    [Category("基础配置")]
    [Description("领域逻辑基类名称空间")]
    public string BaseDomainNameSpace
    {
        get { return baseDomainNameSpace; }
        set { baseDomainNameSpace = value; }
    }
    [Category("基础配置")]
    [Description("业务服务基类名称空间")]
    public string BaseServiceProxyNameSpace
    {
        get { return baseServiceProxyNameSpace; }
        set { baseServiceProxyNameSpace = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据实体类命名格式")]
    public string EntityNameFormat
    {
        get { return entityNameFormat; }
        set { entityNameFormat = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据实体类名称空间")]
    public string EntityNameSpace
    {
        get { return entityNameSpace; }
        set { entityNameSpace = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据实体类输出路径")]
    public string EntityOutputPath
    {
        get { return entityOutputPath; }
        set { entityOutputPath = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据服务类命名格式")]
    public string DataServiceNameFormat
    {
        get { return dataServiceNameFormat; }
        set { dataServiceNameFormat = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据服务类名称空间")]
    public string DataServiceNameSpace
    {
        get { return dataServiceNameSpace; }
        set { dataServiceNameSpace = value; }
    }
    [Category("数据访问层配置")]
    [Description("数据服务类输出路径")]
    public string DataServiceOutputPath
    {
        get { return dataServiceOutputPath; }
        set { dataServiceOutputPath = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("数据服务类命名格式")]
    public string ServiceProxyNameSpace
    {
        get { return serviceProxyNameSpace; }
        set { serviceProxyNameSpace = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("数据服务类名称空间")]
    public string ServiceProxyNameFormat
    {
        get { return serviceProxyNameFormat; }
        set { serviceProxyNameFormat = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("数据服务类输出路径")]
    public string ServiceProxyOutputPath
    {
        get { return serviceProxyOutputPath; }
        set { serviceProxyOutputPath = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("领域逻辑类命名格式")]
    public string DomainNameFormat
    {
        get { return domainNameFormat; }
        set { domainNameFormat = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("领域逻辑类名称空间")]
    public string DomainNameSpace
    {
        get { return domainNameSpace; }
        set { domainNameSpace = value; }
    }
    [Category("业务逻辑层配置")]
    [Description("领域逻辑类输出路径")]
    public string DomainOutputPath
    {
        get { return domainOutputPath; }
        set { domainOutputPath = value; }
    }



    private string _filterTableNames;
    private string _selectTableNames;


    [Category("基础配置")]
    [Description("过滤表前缀")]
    public string FilterTableNames
    {
        get { return _filterTableNames; }
        set { _filterTableNames = value; }
    }


    [Category("基础配置")]
    [Description("选择表前缀")]
    public string SelectTableNames
    {
        get { return _selectTableNames; }
        set { _selectTableNames = value; }
    }

 

    public ICodeConfig BuildNewDefaultConfig()
    {
        CodeConfig codeConfig = new CodeConfig();

        codeConfig.BaseDataBaseProvidrerNameSpace = "CNF.Common.Base.SimpleOrm.DataBaseProvidrer";
        codeConfig.PetapocoNameSpace = "PetaPoco";
        codeConfig.BaseEntityNameSpace = "CNF.Common.Base.SimpleOrm.Entities";
        codeConfig.EntityNameFormat = "HsWdm{0}";
        codeConfig.EntityNameSpace = "HsWdm.Data.Entities.Tables";
        codeConfig.EntityOutputPath = "HsWdm.Data\\Entities\\Tables";


        codeConfig.BaseDataServiceNameSpace = "CNF.Common.Base.SimpleOrm.Data";
        codeConfig.DataServiceNameFormat = "HsWdm{0}DataService";
        codeConfig.DataServiceNameSpace = "HsWdm.Data.DataServices.Tables";
        codeConfig.DataServiceOutputPath = "HsWdm.Data\\DataServices\\Tables";


        codeConfig.BaseServiceProxyNameSpace = "CNF.Common.Base.SimpleOrm.ServiceProxyies";
        codeConfig.ServiceProxyNameFormat = "HsWdm{0}ServiceProxy";
        codeConfig.ServiceProxyNameSpace = "HsWdm.Business.Domain.ServiceProxies.Tables";
        codeConfig.ServiceProxyOutputPath = "HsWdm.Business\\Domain\\ServiceProxies\\Tables";


        codeConfig.BaseDomainNameSpace = "CNF.Common.Base.SimpleOrm.Domain";
        codeConfig.DomainNameFormat = "{0}";
        codeConfig.DomainNameSpace = "HsWdm.Business.Domain";
        codeConfig.DomainOutputPath = "HsWdm.Business\\Domain";
        codeConfig.RemoveTablePrefix = "SRM_";
        codeConfig.FilterTableNames = "sys|aspnet_";
        codeConfig.SelectTableNames = "SRM_";

        return codeConfig;
    }

    public ICodeConfig fromJson(string json)
    {
        return JsonConvert.DeserializeObject<CodeConfig>(json);
    }

    public string toJson()
    {
        return JsonConvert.SerializeObject(this);
    }
}